Skip to content

Fix variance inference issues caused by dataclass replace#21694

Merged
hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:replace
Jul 7, 2026
Merged

Fix variance inference issues caused by dataclass replace#21694
hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:replace

Conversation

@hauntsaninja

@hauntsaninja hauntsaninja commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #17623. We already special case __init__ and __new__, so adding __replace__ here feels alright

Along with #21675 should hopefully get rid of this surprising edge when moving to Python 3.13

I didn't add tests due to fixture issues

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit f5163c0 into python:master Jul 7, 2026
25 checks passed
@hauntsaninja hauntsaninja deleted the replace branch July 7, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Covariance is not inferred for NamedTuple and frozen Dataclasses

1 participant